﻿package igz.fleaxy.util 
{
	import flash.display.Sprite;
	
	/**
	 * @author Intelygenz | www.intelygenz.com
	 */
	public class SpriteUtil 
	{
		
		public function SpriteUtil() {
			
		}

		/**
		 *  Remove every children of the sprite
		 * 
		 * @param	p_sprite Sprite
		 * 
		 * @example $RemoveChildsOf(Container);
		 */
		static public function $RemoveChildsOf(p_sprite:Sprite) :void {
			while ( p_sprite.numChildren > 0 ) {
				p_sprite.removeChildAt(0);
			}
		}

		/**
		 *  Bring to front the indicated sprite
		 * 
		 * @param	p_sprite Sprite
		 * 
		 * @example $BringToFront(Sprite);
		 */
		static public function $BringToFront(p_sprite:Sprite, p_fullRecursive:Boolean = false) :void {
			if ( p_sprite!=null && p_sprite.parent ) {
				p_sprite.parent.setChildIndex(p_sprite, p_sprite.parent.numChildren - 1);
			}
		}
	}
	
}